Skip to content

Add feature / version mismatch errors in C# 9#53662

Open
BillWagner wants to merge 9 commits into
dotnet:mainfrom
BillWagner:feature-version-errors-9
Open

Add feature / version mismatch errors in C# 9#53662
BillWagner wants to merge 9 commits into
dotnet:mainfrom
BillWagner:feature-version-errors-9

Conversation

@BillWagner
Copy link
Copy Markdown
Member

@BillWagner BillWagner commented May 7, 2026

BillWagner added 4 commits May 7, 2026 11:04
Add errors and warnings related to C# 9 features being unsupported before C# 9.
Add related codes that were missed earlier.
Integrate the new codes into the correct themes.
Proofread and finalize.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR consolidates several C# compiler diagnostics related to language feature availability, language version configuration, and runtime feature support into the language-reference “Feature or version missing” article, and updates F1 keyword routing and navigation so those diagnostics land on the new consolidated guidance instead of the generic “Sorry…” page or older per-error pages.

Changes:

  • Expands feature-version-errors.md with coverage for additional diagnostics (including the C# 9 feature/version mismatch errors) and adds structured resolution guidance.
  • Removes CS1617 and CS1638 standalone pages and adds redirects to the consolidated article.
  • Updates F1 keyword mappings and TOC entries so the relevant diagnostics route to the consolidated article.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md Removes several diagnostics from the generic fallback page now that they have dedicated guidance elsewhere.
docs/csharp/misc/cs1638.md Deletes the standalone CS1638 page (replaced by redirect to consolidated article).
docs/csharp/misc/cs1617.md Deletes the standalone CS1617 page (replaced by redirect to consolidated article).
docs/csharp/language-reference/toc.yml Updates navigation and search displayName mappings to point diagnostics to the consolidated “Feature or version missing” article; removes CS1617/CS1638 entries.
docs/csharp/language-reference/compiler-messages/feature-version-errors.md Adds diagnostics (including CS8830/CS8831/CS8888–CS8891) and significantly expands resolution guidance and categorization.
.openpublishing.redirection.csharp.json Adds redirects for removed CS1617 and CS1638 pages to the consolidated article.

Comment thread docs/csharp/language-reference/compiler-messages/feature-version-errors.md Outdated
Comment thread docs/csharp/language-reference/compiler-messages/feature-version-errors.md Outdated
@BillWagner BillWagner marked this pull request as ready for review May 7, 2026 20:20
@BillWagner BillWagner requested a review from a team as a code owner May 7, 2026 20:20
Correct the `<LangVersion>` value in your project file to a valid language version string (**CS1617**, **CS8192**, **CS8303**). The valid values include `default`, `latest`, `preview`, `latestMajor`, or a specific version number such as `7.3`, `8.0`, `9.0`, `10`, `11`, `12`, `13`, or `14`. Don't include leading zeroes in the version number. See [C# language versioning](../language-versioning.md) for the full list of supported values.

> [!TIP]
> To see a list of supported language versions, you reference the table in this article, compile with `-langversion:?`, or temporarily set `<LangVersion>?</LangVersion>` in your project file before building.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> To see a list of supported language versions, you reference the table in this article, compile with `-langversion:?`, or temporarily set `<LangVersion>?</LangVersion>` in your project file before building.
> To see a list of supported language versions, reference the table in this article, compile with `-langversion:?`, or temporarily set `<LangVersion>?</LangVersion>` in your project file before building.

Comment on lines +291 to +293
Upgrade the target framework so the compiler automatically selects the required language version. Each target framework maps to a default C# version. For example, .NET 8 defaults to C# 12, .NET 9 defaults to C# 13, and .NET 10 defaults to C# 14. See the table in [Language version configuration errors](#language-version-configuration-errors) for the full mapping.

Set the `<LangVersion>` element in your project file to the required version or higher. For example, to enable C# 12 features, add `<LangVersion>12</LangVersion>` to a `<PropertyGroup>` in your project file.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Upgrade the target framework so the compiler automatically selects the required language version. Each target framework maps to a default C# version. For example, .NET 8 defaults to C# 12, .NET 9 defaults to C# 13, and .NET 10 defaults to C# 14. See the table in [Language version configuration errors](#language-version-configuration-errors) for the full mapping.
Set the `<LangVersion>` element in your project file to the required version or higher. For example, to enable C# 12 features, add `<LangVersion>12</LangVersion>` to a `<PropertyGroup>` in your project file.
- Upgrade the target framework so the compiler automatically selects the required language version. Each target framework maps to a default C# version. For example, .NET 8 defaults to C# 12, .NET 9 defaults to C# 13, and .NET 10 defaults to C# 14. See the table in [Language version configuration errors](#language-version-configuration-errors) for the full mapping.
- Set the `<LangVersion>` element in your project file to the required version or higher. For example, to enable C# 12 features, add `<LangVersion>12</LangVersion>` to a `<PropertyGroup>` in your project file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C# Errors and diagnostics] - Add diagnostics on feature & version mismatch in C# 9

3 participants